﻿/**
 * @file error_category.hpp
 * @date 2021/04/21 21:08
 *
 * @author harrybao (harrybao@123u.com)
 *
 * @brief 错误分类
 *
 * @version v1.0.0
 *
 * @copyright Copyright © 2021 All Rights Reserved 上海欢乐互娱网络科技有限公司
 *
 * @par history:
 * <table>
 * <tr><th>Date                     <th>Version     <th>Author <th>Description
 * <tr><td>2021/04/21 21:08         <td>1.0.0       <td>harrybao
 * <td>创建初始版本
 * </table>
 */

#pragma once

#include <system_error>

#include "error/service_error_code.h"

namespace {

constexpr char kErrUnknowMsg[] = "未知";
constexpr char kErrSuccessMsg[] = "成功";
constexpr char kErrFailedMsg[] = "失败";

constexpr char kErrInvalidRoleUuidMsg[] = "非法角色id";
constexpr char kErrInvalidGuildIdMsg[] = "非法公会id";
constexpr char kErrInvalidToken[] = "非法凭证";
constexpr char kErrRegisterFailed[] = "注册失败";

constexpr char kErrGuildAddFailed[] = "添加公会失败";
constexpr char kErrGuildDelFailed[] = "删除公会失败";

constexpr char kErrGuildAlreadyExist[] = "公会已存在";
constexpr char kErrGuildNotExist[] = "公会不存在";

constexpr char kErrGuildSystemNotOpen[] = "公会系统未开放";

constexpr char kErrGuildBriefLoadFailed[] = "公会简略信息模块加载失败";
constexpr char kErrGuildBriefSaveFailed[] = "公会简略信息模块保存失败";
constexpr char kErrGuildBriefNameExist[] = "公会名字已存在";
constexpr char kErrGuildBriefGiveItemIdInvalid[] = "上交公会道具id非法";
constexpr char kErrGuildBriefGiveItemNumInvalid[] = "上交公会道具数量非法";

constexpr char kErrGuildMembersLoadFailed[] = "公会成员模块加载失败";
constexpr char kErrGuildMembersSaveFailed[] = "公会成员模块保存失败";
constexpr char kErrGuildMembersFull[] = "公会成员已满";
constexpr char kErrGuildMembersNoPermission[] = "公会成员没有职责";
constexpr char kErrGuildMembersRoleNotExist[] = "公会成员不存在";
constexpr char kErrGuildMembersAddFailed[] = "公会成员添加失败";
constexpr char kErrGuildMembersAddIdFailed[] = "公会成员id添加失败";
constexpr char kErrGuildMembersDelIdFailed[] = "公会成员id删除失败";
constexpr char kErrGuildMembersDutyChairman[] = "公会成员职责是会长";
constexpr char kErrGuildMembersInvalidDuty[] = "公会成员职责非法";
constexpr char kErrGuildMembersDutyFull[] = "公会成员职责已满";
constexpr char kErrGuildMembersDutyPermissionDenied[] = "公会成员职责权限拒绝";
constexpr char kErrGuildMembersWelfareAwarded[] = "公会成员已经领取过奖励";
constexpr char kErrGuildMembersRoleNotInSameGuild[] = "公会成员不在同一个公会";

constexpr char kErrGuildApplicationLoadFailed[] = "公会申请模块加载失败";
constexpr char kErrGuildApplicationSaveFailed[] = "公会申请模块保存失败";
constexpr char kErrGuildApplicationFull[] = "公会申请模块申请已满";
constexpr char kErrGuildApplicationAlreadyExist[] = "公会申请模块申请已存在";

constexpr char kErrGuildModRedEnvelopeLoadFailed[] = "公会红包模块加载失败";
constexpr char kErrGuildModRedEnvelopeSaveFailed[] = "公会红包模块保存失败";
constexpr char kErrGuildModRedEnvelopeInvalidCount[] =
    "公会红包模块红包数量非法";
constexpr char kErrGuildModRedEnvelopeCreateFailed[] =
    "公会红包模块创建红包失败";
constexpr char kErrGuildModRedEnvelopeAddFailed[] = "公会红包模块添加红包失败";
constexpr char kErrGuildModRedEnvelopeNotExist[] = "公会红包模块红包不存在";

constexpr char kErrGuildModRepositoryLoadFailed[] = "公会仓库模块加载失败";
constexpr char kErrGuildModRepositorySaveFailed[] = "公会仓库模块保存失败";
constexpr char kErrGuildModRepositoryItemNotExist[] = "公会仓库模块道具不存在";
constexpr char kErrGuildModRepositoryAttentionFailed[] =
    "公会仓库模块关注道具失败";
constexpr char kErrGuildModRepositoryGenItemUuidFailed[] =
    "公会仓库模块生成道具唯一id失败";
constexpr char kErrGuildModRepositoryAddItemFailed[] =
    "公会仓库模块添加道具失败";
constexpr char kErrGuildModRepositoryDelItemFailed[] =
    "公会仓库模块删除道具失败";
constexpr char kErrGuildModBuildingLoadFailed[] = "公会建筑模块加载失败";
constexpr char kErrGuildModBuildingSaveFailed[] = "公会建筑模块保存失败";
constexpr char kErrGuildModBuildingNotExist[] = "公会建筑模块建筑不存在";
constexpr char kErrGuildModBuildingUpgrading[] = "公会建筑模块升级中";
constexpr char kErrGuildModBuildingTopLevelLimited[] = "公会建筑模块升到最高等级";

/**
 * @brief 公会服务错误码分类
 *
 */
struct GuildServiceErrorCategory : std::error_category {
  const char* name() const noexcept override {
    return "GuildServiceErrorCategory";
  }
  std::string message(int ev) const override {
    auto e = static_cast<guild_service::ErrorCode>(ev);
    switch (e) {
      case guild_service::ErrorCode::ERR_SUCCESS:
        return kErrSuccessMsg;
        break;
      case guild_service::ErrorCode::ERR_FAILED:
        return kErrFailedMsg;
        break;
      case guild_service::ErrorCode::ERR_INVALID_ROLE_UUID:
        return kErrInvalidRoleUuidMsg;
        break;
      case guild_service::ErrorCode::ERR_INVALID_GUILD_ID:
        return kErrInvalidGuildIdMsg;
        break;
      case guild_service::ErrorCode::ERR_INVALID_TOKEN:
        return kErrInvalidToken;
        break;
      case guild_service::ErrorCode::ERR_REGISTER_FAILED:
        return kErrRegisterFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_ADD_FAILED:
        return kErrGuildAddFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_DEL_FAILED:
        return kErrGuildDelFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_ALREADY_EXIST:
        return kErrGuildAlreadyExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_NOT_EXIST:
        return kErrGuildNotExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_SYSTEM_NOT_OPEN:
        return kErrGuildSystemNotOpen;
        break;
      case guild_service::ErrorCode::ERR_GUILD_BRIEF_LOAD_FAILED:
        return kErrGuildBriefLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_BRIEF_SAVE_FAILED:
        return kErrGuildBriefSaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_BRIEF_NAME_EXIST:
        return kErrGuildBriefNameExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_BRIEF_GIVE_ITEM_ID_INVALID:
        return kErrGuildBriefGiveItemIdInvalid;
        break;
      case guild_service::ErrorCode::ERR_GUILD_BRIEF_GIVE_ITEM_NUM_INVALID:
        return kErrGuildBriefGiveItemNumInvalid;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_LOAD_FAILED:
        return kErrGuildMembersLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_SAVE_FAILED:
        return kErrGuildMembersSaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_FULL:
        return kErrGuildMembersFull;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_NO_PERMISSION:
        return kErrGuildMembersNoPermission;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_ROLE_NOT_EXIST:
        return kErrGuildMembersRoleNotExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_ADD_FAILED:
        return kErrGuildMembersAddFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_ADD_ID_FAILED:
        return kErrGuildMembersAddIdFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_DEL_ID_FAILED:
        return kErrGuildMembersDelIdFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_DUTY_CHAIRMAN:
        return kErrGuildMembersDutyChairman;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_INVALID_DUTY:
        return kErrGuildMembersInvalidDuty;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_DUTY_FULL:
        return kErrGuildMembersDutyFull;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_DUTY_PERMISSION_DENIED:
        return kErrGuildMembersDutyPermissionDenied;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_WELFARE_AWARDED:
        return kErrGuildMembersWelfareAwarded;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MEMBERS_ROLE_NOT_IN_SAME_GUILD:
        return kErrGuildMembersRoleNotInSameGuild;
        break;
      case guild_service::ErrorCode::ERR_GUILD_APPLICATION_LOAD_FAILED:
        return kErrGuildApplicationLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_APPLICATION_SAVE_FAILED:
        return kErrGuildApplicationSaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_APPLICATION_FULL:
        return kErrGuildApplicationFull;
        break;
      case guild_service::ErrorCode::ERR_GUILD_APPLICATION_ALREADY_EXIST:
        return kErrGuildApplicationAlreadyExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_LOAD_FAILED:
        return kErrGuildModRedEnvelopeLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_SAVE_FAILED:
        return kErrGuildModRedEnvelopeSaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_INVALID_COUNT:
        return kErrGuildModRedEnvelopeInvalidCount;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_CREATE_FAILED:
        return kErrGuildModRedEnvelopeCreateFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_ADD_FAILED:
        return kErrGuildModRedEnvelopeAddFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_RED_ENVELOPE_NOT_EXIST:
        return kErrGuildModRedEnvelopeNotExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_REPOSITORY_LOAD_FAILED:
        return kErrGuildModRepositoryLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_REPOSITORY_SAVE_FAILED:
        return kErrGuildModRepositorySaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_REPOSITORY_ITEM_NOT_EXIST:
        return kErrGuildModRepositoryItemNotExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_REPOSITORY_ATTENTION_FAILED:
        return kErrGuildModRepositoryAttentionFailed;
        break;
      case guild_service::ErrorCode::
          ERR_GUILD_MOD_REPOSITORY_GEN_ITEM_UUID_FAILED:
        return kErrGuildModRepositoryGenItemUuidFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_REPOSITORY_ADD_ITEM_FAILED:
        return kErrGuildModRepositoryAddItemFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_BUILDING_LOAD_FAILED:
        return kErrGuildModBuildingLoadFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_BUILDING_SAVE_FAILED:
        return kErrGuildModBuildingSaveFailed;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_BUILDING_BUILDING_NOT_EXIST:
        return kErrGuildModBuildingNotExist;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_BUILDING_UPGRADING:
        return kErrGuildModBuildingUpgrading;
        break;
      case guild_service::ErrorCode::ERR_GUILD_MOD_BUILDING_TOP_LEVEL_LIMITED:
        return kErrGuildModBuildingTopLevelLimited;
        break;
      default:
        return kErrUnknowMsg;
        break;
    }

    return "";
  }
};

const GuildServiceErrorCategory theGuildServiceErrorCategory{};

}  // namespace